#include<bits/stdc++.h>
using namespace std;
int n,m;
double l;
double k;
double bn[100005];
double v[100005];
double a[100005];
double dian[100005];
pair<double,double>wow[100005];
int www;
int t;
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>t;
    www=0;
    for(int tt=0;tt<t;tt++){
        cin>>n>>m>>l>>k;
        www=0;
        for(int i=0;i<n;i++){
            cin>>bn[i]>>v[i]>>a[i];
            if(v[i]>=k&&a[i]>0){
                wow[www].first=bn[i];
                wow[www].second=l;
                www++;
            }
            else if(v[i]>k&&a[i]>=0){
                wow[www].first=bn[i];
                wow[www].second=l;
                www++;
            }
            else if(v[i]>k&&a[i]<k){
                wow[www].first=bn[i];
                wow[www].second=min(l,bn[i]+((k*k)-(v[i]*v[i]))/(2*a[i]));
                www++;
            }
            else if(v[i]<=k&&a[i]>0){
                if((bn[i]+(((k*k)-(v[i]*v[i]))/(2*a[i])))<=l){
                    wow[www].first=bn[i]+(((k*k)-(v[i]*v[i]))/(2*a[i]));
                    wow[www].second=l;
                    www++;
                }
            }
        }
        //for(int i=0;i<www;i++)cout<<wow[i].first<<' '<<wow[i].second<<endl;
        for(int i=0;i<m;i++){
            cin>>dian[i];
        }
        int pls=0;
        for(int i=0;i<www;i++){
            int mid=0;
            bool flag=0;
            for(int left=0,right=m; ;mid=(left+right)>>1){
                if(dian[mid]>wow[i].second)right=mid;
                else if(dian[mid]<wow[i].first)left=mid+1;
                else{
                    flag=1;
                    break;
                }
                if(left==right)break;
            }
            if(!flag){
                wow[i].first=999999999;
                pls++;
            }
        }
        sort(wow,wow+www);
        www-=pls;
        cout<<www<<' ';
        for(int i=0;i<www;i++){
                for(int j=i+1;j<www;j++){
                    if(wow[j].second<=wow[i].second)wow[i].first=-1;
                }

        }
        int ans=0;
        int last=-1;
        for(int i=0,j=0;i<www&&j<m;i++){
            if(wow[i].first==-1){
                continue;
            }
            else if(last>=wow[i].first&&last<=wow[i].second){
                continue;
            }
            else if(dian[j]<wow[i].first){
                j++;
                i--;
                continue;
            }
            else if(j+1==m&&dian[j]<=wow[i].second){
                j++;
                ans++;
                break;
            }
            else if(dian[j+1]<=wow[i].second){
                j++;
                i--;
                continue;
            }
            else {
                last=dian[j];
                j++;
                ans++;
            }

        }
        cout<<m-ans<<endl;;
    }
    return 0;
}
